<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title></title>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script>
		$(function(){
			$("#btnSave").button({
	            icons: {
	                primary: "ui-icon-disk"
	            }
			}).click(function(){
				if(confirm('คุณต้องการยืนยันการส่งข้อมูล?')==true){
					disableField(["btnSave","btnBack","btnRollBack"]);
					$("#btnSave").addClass("ui-button-disabled ui-state-disabled");
					$("#btnBack").addClass("ui-button-disabled ui-state-disabled");
					$("#btnRollBack").addClass("ui-button-disabled ui-state-disabled");
					$("#saveForm").submit();
				}
			});
			$("#btnRollBack").button({
	            icons: {
	                primary: "ui-icon-arrowreturnthick-1-w"
	            }
			}).click(function(){
				$("#job").val("rollBack");
				$("#saveForm").submit();
			});
			$("#btnBack").button({
	            icons: {
	                primary: "ui-icon-arrowreturnthick-1-w"
	            }
			}).click(function(){
				$("#job").val("back");
				$("#saveForm").submit();
			});
		});
		</script>
	</head>
	<body>
		<c:set var="auth" value="${el:getMapValue(menuAuth, 'ACC60305')}"/>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="saveForm" id="saveForm" action="${pageContext.request.contextPath}/acc6" method="post">
		<input type="hidden" name="app" id="app" value="ACC60305"/>
		<input type="hidden" name="job" id="job" value="${job}"/>
		<input type="hidden" name="docNo" id="docNo" value="${docNo}"/>
		<input type="hidden" name="budgetYear" id="budgetYear" value="${expenseBean.budgetYear}"/>
		<input type="hidden" name="provinceId" id="provinceId" value="${expenseBean.provinceId}"/>
		<table width="100%" class="ui-widget ui-widget-content" border="0">
			<tr>
				<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC60305}</b></th>
			</tr>
			<tr>
				<td class="bold" width="15%">เลขที่เอกสาร : </td>
				<td>${docNo}</td>
			</tr>
			<tr>
				<td class="bold">จังหวัด : </td>
				<td>${provinceName}</td>
			</tr>
			<tr>
				<td class="bold">ปีงบประมาณ : </td>
				<td>${expenseBean.budgetYear}</td>
			</tr>
			<tr>
				<td class="bold">วันที่ทำรายการ : </td>
				<td>${el:dateTh(expenseBean.createdDate)}</td>
			</tr>
		<%-- 	<tr>
				<td class="bold">วันที่จ่าย : </td>
				<td>${el:dateTh(expenseBean.expenseDate)}</td>
				<input type="hidden" name="expenseDate" id="expenseDate" value="${el:dateTh(expenseBean.expenseDate)}"/>
			</tr> --%>
			<tr>
				<td class="bold">ชื่อการจ่าย : </td>
				<td>${expenseBean.expenseSubject}</td>
			</tr>
			<tr>
				<td class="bold" valign="top">คำอธิบายการจ่าย : </td>
				<td>${expenseBean.expenseDesc}</td>
			</tr>
			<tr>
				<td colspan="2">
				<fieldset id="payDetail">
					<legend>รายละเอียดการจ่ายโอน</legend>
					<table width="100%" class="acc67-grid ui-widget ui-widget-content" id="payTableDetail">
						<tr>
							<th align="center" class="ui-state-default" width="7%">เอกสารอ้างอิง</th>
							<th align="center" class="ui-state-default" width="9%">กองทุนย่อยเฉพาะด้าน</th>
							<th align="center" class="ui-state-default" width="9%">หน่วยบริการ/คู่สัญญา</th>
							<th align="center" class="ui-state-default" width="5%">เลขที่ cheque</th>
							<th align="center" class="ui-state-default" width="5%">วันที่สั่งจ่าย</th>
							<th align="center" class="ui-state-default" width="5%">วันที่ขึ้นเงิน</th>
							<th align="center" class="ui-state-default" width="9%">หมวดการจ่าย</th>
							<th align="center" class="ui-state-default" width="7%">จำนวนเงิน</th>
							<th align="center" class="ui-state-default" width="5%">ภาษี</th>
							<th align="center" class="ui-state-default" width="9%">ชื่อผู้รับผิดชอบ</th> 
							<th align="center" class="ui-state-default">ชื่อโครงการ/คำอธิบาย</th>
							<th align="center" class="ui-state-default" width="5%">เงินยืม</th>
						</tr>
						<c:if test="${!empty listExpenseCheque}">
							<c:forEach items="${listExpenseCheque}" var="data" varStatus="x">
									<c:set var="reasonDesc" value="${el:getReasonDesc(data.transactionTimestamp)}" />
										<c:if test="${reasonDesc == '00:SUCCESS'}">
										<tr style="background-color: #8eee81;">
										</c:if>
										<c:if test="${reasonDesc == ''}">
										<tr>
										</c:if>
										<c:if test="${reasonDesc != '00:SUCCESS' && reasonDesc != ''}">
										<tr style="background-color: red;" title="${reasonDesc}">
										</c:if>
										<td align="center">${data.refNo}</td>
										<td align="left"><span title="${data.allocateName}">${data.allocateCode} : ${data.allocateSub}</span></td>
										<td align="left"><span title="${data.venderName}">${data.venderSub}</span></td>
										<td align="center">${data.chequeNo}</td>
										<td align="center">${el:dateTh(data.chequeDate)}</td>
										<td align="center">${el:dateTh(data.chequeReceivingDate)}</td>
										<td align="left">
											<c:if test="${fn:length(el:getDataUtil('CAT',data.categoryId)) > 10}">
												<span title="${el:getDataUtil('CAT',data.categoryId)}">${fn:substring(el:getDataUtil('CAT',data.categoryId),0,10)}...</span>
											</c:if>
											<c:if test="${fn:length(el:getDataUtil('CAT',data.categoryId)) <= 10}">
												<span title="${el:getDataUtil('CAT',data.categoryId)}">${el:getDataUtil('CAT',data.categoryId)}</span>
											</c:if>
										</td>
										<td align="right"><fmt:formatNumber pattern="#,##0.00" value="${data.chequeAmount}" /></td>
										<td align="right"><fmt:formatNumber pattern="#,##0.00" value="${data.taxValue}" /></td>
										<td align="left">${data.responsibleName}</td>
										<td align="left">${data.chequeDesc}</td>
										<td>
											<input type="checkbox" ${data.isBorrow=='Y'?'checked':''} disabled="disabled"/>
										</td>
										<input type="hidden" name="refNo" value="${data.refNo}"/>
										<input type="hidden" name="categoryId" value="${data.categoryId}"/>
										<input type="hidden" name="venderCode" value="${data.venderCode}"/>
										<input type="hidden" name="allocateCode" value="${data.allocateCode}"/>
										<input type="hidden" name="chequeAmount" value="${data.chequeAmount}"/>
										<input type="hidden" name="chequeSeq" value="${data.chequeSeq}"/>
										<input type="hidden" name="chequeNo" value="${data.chequeNo}"/>
										<input type="hidden" name="chequeDate" value="${el:dateTh(data.chequeDate)}"/>
										<input type="hidden" name="isBorrow" value="${data.isBorrow}"/>
										<input type="hidden" name="taxValue" value="${data.taxValue}"/>
									</tr>
							</c:forEach>
						</c:if>
					</table>
				</fieldset>
				</td>			
			</tr>
			<tr>
				<td colspan="2" align="center">
					<c:if test="${expenseBean.expenseStatus == 'A'}">
						<c:if test="${fn:contains(auth, 'U')}">
							<button type="button" name="btnSave" id="btnSave" class="acc67-button">ยืนยันการส่งข้อมูล</button>
							<button type="button" name="btnRollBack" id="btnRollBack" class="acc67-button">ส่งคืนแก้ไข</button>
						</c:if>
						<button type="button" name="btnBack" id="btnBack" class="acc67-button">ย้อนกลับ</button>
					</c:if>
					<c:if test="${expenseBean.expenseStatus != 'A'}">
						<button type="button" name="btnBack" id="btnBack" class="acc67-button">ย้อนกลับ</button>
					</c:if>
				</td>
			</tr>
		</table>
		</form>
	</body>
</html>